package cn.yotta.user.web.autoconfiguration.context.user;

import cn.yotta.user.web.autoconfiguration.provider.LoginUser;

/**
 * @author wyaoyao
 * @date 2022/11/8 11:04
 */
public class ThreadLocalUserContextStrategy implements UserContextStrategy {

    private static final ThreadLocal<LoginUser> LOGIN_USER_THREAD_LOCAL = new ThreadLocal<LoginUser>();


    @Override
    public void clear() {
        LOGIN_USER_THREAD_LOCAL.remove();
    }

    @Override
    public LoginUser get() {
        return LOGIN_USER_THREAD_LOCAL.get();
    }

    @Override
    public void set(LoginUser user) {
        LOGIN_USER_THREAD_LOCAL.set(user);
    }
}
